/*
抽象工厂
生产产品族

https://www.zhihu.com/question/27125796/answer/1615074467
*/

package abstract_factory

import "fmt"

type Keyboard interface {
	Print()
}

type Monitor interface {
	Play()
}

type Factory interface {
	CreateKeyboard() Keyboard
	CreateMonitor() Monitor
}

type DellFactory struct {
}

type HpFactory struct {
}

var _ Factory = (*DellFactory)(nil)
var _ Factory = (*HpFactory)(nil)

type dellKeyboard struct {
}

func (k *dellKeyboard) Print() {
	fmt.Println("dell keyboard")
}

type hpKeyboard struct {
}

func (k *hpKeyboard) Print() {
	fmt.Println("hp keyboard")
}

type dellMonitor struct {
}

func (m *dellMonitor) Play() {
	fmt.Println("dell monitor")
}

type hpMonitor struct {
}

func (m *hpMonitor) Play() {
	fmt.Println("hp monitor")
}

func (f *DellFactory) CreateKeyboard() Keyboard {
	return &dellKeyboard{}
}

func (f *DellFactory) CreateMonitor() Monitor {
	return &dellMonitor{}
}

func (f *HpFactory) CreateKeyboard() Keyboard {
	return &hpKeyboard{}
}

func (f *HpFactory) CreateMonitor() Monitor {
	return &hpMonitor{}
}
